import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { TaskLogVO, TaskLogForm, TaskLogQuery } from '@/api/agriculture/taskLog/types';

/**
 * 查询批次任务日志列表
 * @param query
 * @returns {*}
 */

export const listTaskLog = (query?: TaskLogQuery): AxiosPromise<TaskLogVO[]> => {
  return request({
    url: '/agriculture/taskLog/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询批次任务日志详细
 * @param logId
 */
export const getTaskLog = (logId: string | number): AxiosPromise<TaskLogVO> => {
  return request({
    url: '/agriculture/taskLog/' + logId,
    method: 'get'
  });
};

/**
 * 新增批次任务日志
 * @param data
 */
export const addLog = (data: TaskLogForm) => {
  return request({
    url: '/agriculture/taskLog',
    method: 'post',
    data: data
  });
};

/**
 * 修改批次任务日志
 * @param data
 */
export const updateTaskLog = (data: TaskLogForm) => {
  return request({
    url: '/agriculture/taskLog',
    method: 'put',
    data: data
  });
};

/**
 * 删除批次任务日志
 * @param logId
 */
export const delTaskLog = (logId: string | number | Array<string | number>) => {
  return request({
    url: '/agriculture/taskLog/' + logId,
    method: 'delete'
  });
};
